gdk: Don't require allocating window background colors anymore
authorBenjamin Otte <otte@redhat.com>
Sat, 31 Jul 2010 09:20:46 +0000 (11:20 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 10 Aug 2010 19:02:30 +0000 (21:02 +0200)
X!! allocates the colors itself now.

gdk/gdkoffscreenwindow.c
gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c

index 257abea4d4192cd865fa734f30ca4af30c3df3f5..c8fc4187aec4b5ea60546ef366dadde66886ec54 100644 (file)
@@ -676,10 +676,8 @@ gdk_offscreen_window_set_background (GdkWindow      *window,
                                     const GdkColor *color)
 {
   GdkWindowObject *private = (GdkWindowObject *)window;
-  GdkColormap *colormap = gdk_drawable_get_colormap (window);
 
   private->bg_color = *color;
-  gdk_colormap_query_color (colormap, private->bg_color.pixel, &private->bg_color);
 
   if (private->bg_pixmap &&
       private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
index 335eca2ab846b0be808b7f4e6ccde93b4b0e40ac..f39d2ca35eb10f844a8e185da5287f00abee0a1a 100644 (file)
@@ -7072,9 +7072,6 @@ gdk_window_get_background (GdkWindow *window,
  * you're an application - or gtk_style_set_background() - if you're
  * implementing a custom widget.)
  *
- * The @color must be allocated; gdk_rgb_find_color() is the best way
- * to allocate a color.
- *
  * See also gdk_window_set_background_pixmap().
  */
 void
@@ -7082,7 +7079,6 @@ gdk_window_set_background (GdkWindow      *window,
                           const GdkColor *color)
 {
   GdkWindowObject *private;
-  GdkColormap *colormap = gdk_drawable_get_colormap (window);
   GdkWindowImplIface *impl_iface;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
@@ -7090,7 +7086,6 @@ gdk_window_set_background (GdkWindow      *window,
   private = (GdkWindowObject *) window;
 
   private->bg_color = *color;
-  gdk_colormap_query_color (colormap, private->bg_color.pixel, &private->bg_color);
 
   if (private->bg_pixmap &&
       private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
index 1339b7bbb4e974421fcff61ebe2e69528856300f..bf919cbd150c549e977800975f18f0bd486a2f5b 100644 (file)
@@ -2637,8 +2637,17 @@ static void
 gdk_window_x11_set_background (GdkWindow      *window,
                                const GdkColor *color)
 {
+  GdkColor allocated = *color;
+
+  if (!gdk_colormap_alloc_color (gdk_drawable_get_colormap (window),
+                                 &allocated,
+                                 TRUE, TRUE))
+    return;
+
   XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
-                       GDK_WINDOW_XID (window), color->pixel);
+                       GDK_WINDOW_XID (window), allocated.pixel);
+
+  gdk_colormap_free_colors (gdk_drawable_get_colormap (window), &allocated, 1);
 }
 
 static void